<?php
namespace app\common\logic;

class Common
{

    //获取标准列表
    static function getBiaozhunList($param){

        $apiService = new ApiService();
/*        $url = 'http://www.bendilpdceshi.com/special_medicine/special_medicine/agelist';*/
        $url ='http://sy.foodvip.net/api2/public/api.php'.'?s=api/special_medicine/special_medicine/agelist';
        $url = $apiService->getUrl($url,$param);
      /*  var_dump($url);
        die;*/
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $res = curl_exec($curl);
        curl_close($curl);

        $data = json_decode($res,true);
        return $data;
    }


    static function getBiaozhunLists($param,$url){
        $apiService = new ApiService();
        $url ='http://sy.foodvip.net/api2/public/api.php'.'?s=api/special_medicine/special_medicine/'.$url;
        $url = $apiService->getUrl($url,$param);
     /*   var_dump($url);
        die;*/
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $res = curl_exec($curl);
        curl_close($curl);
        $data = json_decode($res,true);
        return $data;
    }

    static function getBiaozhunListsq($param,$url){
        $apiService = new ApiService();
        $url ='www.bendilpdceshi.com/api.php'.'?s=api/special_medicine/special_medicine/'.$url;
        $url = $apiService->getUrl($url,$param);
        /*   var_dump($url);
           die;*/
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $res = curl_exec($curl);
        curl_close($curl);
        $data = json_decode($res,true);
        return $data;
    }
    //根据标准名称/标准文号索取标准ID
    static function getBiaozhunIds($bf_title){
        $apiService = new ApiService();
        $param = [
            'customer_id'=>259,
            'quanku'=>1,
            //'field'=>'itemid',
            'num'=>50,
            'is_accurate'=>$bf_title,
        ];
        $url ='http://sy.foodvip.net/api2/public/api.php'.'?s=api/biaozhun/biaozhun/lists';
        $url = $apiService->getUrl($url,$param);
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $res = curl_exec($curl);
        curl_close($curl);
        $data = json_decode($res,true);
        return $data;
    }



    //获取一个标准信息
    static function getBiaozhunDetail($param){
        $apiService = new ApiService();
        $url = config('system.api_host').'?s=api/biaozhun/biaozhun/content.json';
        $url = $apiService->getUrl($url,$param);
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $res = curl_exec($curl);
        curl_close($curl);
        $data = json_decode($res,true);
        return $data;
    }


    //获取法规
    static function getFaguiList($param){
        $apiService = new ApiService();
        $url = config('system.api_host').'?s=api/fagui/fagui/lists';
        $url = $apiService->getUrl($url,$param);
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $res = curl_exec($curl);
        curl_close($curl);
        $data = json_decode($res,true);
        return $data;
    }
    //根据法规名称/法规文号索取法规ID
    static function getFaguiIds($bf_title){
        $apiService = new ApiService();
        $param = [
            'customer_id'=>config('system.customer_id'),
            'quanku'=>1,
            //'field'=>'itemid',
            'num'=>50,
            'is_accurate'=>$bf_title,
        ];
        $url = config('system.api_host').'?s=api/fagui/fagui/lists';
        $url = $apiService->getUrl($url,$param);
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $res = curl_exec($curl);
        curl_close($curl);
        $data = json_decode($res,true);
        return $data;
    }

    //获取一个法规信息
    static function getFaguiDetail($param){
        $apiService = new ApiService();
        $url = config('system.api_host').'?s=api/fagui/fagui/content.json';
        $url = $apiService->getUrl($url,$param);
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $res = curl_exec($curl);
        curl_close($curl);
        $data = json_decode($res,true);
        return $data;
    }



}